package com.fm.openinstall.d;

import java.nio.*;
import java.util.*;

public class f implements Cloneable
{
    private final long a;
    private final List b;

    public f(final long a) {
        this.b = new ArrayList();
        this.a = a;
    }

    private byte[] a(final int n) {
        for (final e e : this.b) {
            if ((int)e.a == n) {
                return ((g)e.b).a();
            }
        }
        return null;
    }

    private void b(final int n) {
        final Iterator<e> iterator = (Iterator<e>)this.b.iterator();
        while (iterator.hasNext()) {
            if ((int)iterator.next().a == n) {
                iterator.remove();
            }
        }
    }

    public long a() {
        return this.a + this.c();
    }

    public void a(final int n, final byte[] array) {
        final byte[] array2 = new byte[array.length + 8 + 4];
        final ByteBuffer order = ByteBuffer.wrap(array2).order(ByteOrder.LITTLE_ENDIAN);
        order.putLong(array2.length - 8).putInt(n);
        order.put(array);
        final e e = new e(n, new g(array2));
        final ListIterator<e> listIterator = this.b.listIterator();
        while (listIterator.hasNext()) {
            if ((int)listIterator.next().a == n) {
                listIterator.set(e);
                return;
            }
        }
        this.b.add(e);
    }

    public void a(final byte[] array) {
        if (array == null) {
            this.b(987894612);
            return;
        }
        this.a(987894612, array);
    }

    public long b() {
        return this.a;
    }

    public long c() {
        final Iterator<e> iterator = this.b.iterator();
        long n = 32L;
        while (iterator.hasNext()) {
            n += ((g)iterator.next().b).a.length;
        }
        return n;
    }

    public byte[] d() {
        return this.a(987894612);
    }

    public ByteBuffer[] e() {
        final ByteBuffer[] array = new ByteBuffer[this.b.size() + 2];
        final long n = this.c() - 8L;
        array[0] = (ByteBuffer)ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(n).flip();
        final Iterator<e> iterator = this.b.iterator();
        int n2 = 1;
        while (iterator.hasNext()) {
            array[n2] = ByteBuffer.wrap(((g)iterator.next().b).a);
            ++n2;
        }
        array[n2] = (ByteBuffer)ByteBuffer.allocate(24).order(ByteOrder.LITTLE_ENDIAN).putLong(n).putLong(2334950737559900225L).putLong(3617552046287187010L).flip();
        return array;
    }

    public f f() {
        final f f = new f(this.a);
        for (final e e : this.b) {
            f.b.add(new e(e.a, e.b));
        }
        return f;
    }
}
